package decisionalalgorithms.guialgorithms.converters;

import com.sun.istack.Nullable;
import decisionalalgorithms.guialgorithms.commands.PriorityCommand;
import decisionalalgorithms.guialgorithms.domain.Priority;
import lombok.Synchronized;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

@Component
public class PriorityCommandToPriority implements Converter<PriorityCommand, Priority> {
    @Synchronized
    @Nullable
    @Override
    public Priority convert(PriorityCommand source) {
        if (source ==null) {
            return null;
        }
        final Priority priority = new Priority();
        priority.setId(source.getId());
        priority.setPriority(source.getPriority());
        return priority;
    }
}
